<template>
	<view class="box">
		<view>
			<drawer :show="isDrawerOpen" @close="closeDrawer"></drawer>
		</view>
		<view>
			<languageMask :show="isOpenMask" @close="closeMask" @languageChanged="refreshLanguage"></languageMask>
		</view>
		<view class="head">
			<view style="display: flex;align-items: center;">
				<image src="../../static/qukuailian2_slices/danlieliebiao.png" class="list" @click="openDrawer"></image>
				<image src="../../static/caifubeifen_slices/lujing9.png" mode="" class="back" @click="toDetails">
				</image>
			</view>
			<view class="head-title">
				<view class="vtitle">{{$data.$language.atitle}}</view>
			</view>
			<view class="right-head">
				<image src="../../static/qianbaobeifen2_slices/diqiugenghuan.png" mode="" class="language"
					@click="openMask">
				</image>
			</view>
		</view>
		<view class="headBg">
			<view class="transfer" @click="tranAccBtn">
				{{$data.$language.tranAcc}}
			</view>
			<view class="accounts" @click="RechargeBtn">
				<!-- {{$data.$language.Recharge}} -->
				{{$data.$language.AssetAllocation}}

			</view>

			<view class="line1">
				<view class="total">
					<view>{{ array[index].name }}</view>
					<!-- {{$data.$language.dtest}} -->
					<!-- <picker @change="bindPickerChange" :value="index" :range="array" range-key="name">
					          <view>{{ array[index].name }}</view>
					</picker> -->
					<!-- <image src="../../static/qianbaobeifen2_slices/jiantou.png" mode=""></image> -->
				</view>
				<!-- <image src="../../static/qianbaobeifen2_slices/jiantou.png" mode=""></image> -->
				<!-- <view class="mobx-text">
					{{$data.$language.levelCar}}：{{levelSl}}
				</view> -->
			</view>
			<view class="line2">
				<view class="word1">
					<span v-if="index==2"
						style="font-size: 32rpx;margin-right: 8rpx;">{{$data.$language.numberList}}:</span>
					{{count_usdt}}
				</view>
				<view class="word2" v-if="index!=2">
					USDT
				</view>
				<view class="word1" v-if="index==2">
					<span style="font-size: 32rpx;margin-right: 8rpx;">{{$data.$language.worth}}:
					</span>{{(parseInt(count_usdt*wone_usdt*100)/100).toFixed(2)}}
					<span style="margin-left: 8rpx;font-size: 28rpx;">USDT</span>
				</view>
			</view>
			<!-- <view class="line2">
				<view class="word1">
					123 
				</view>
				<view class="word2">
					WOO
				</view>
			</view> -->
			<view class="line3">
			</view>
			<view class="line4">
				<view class="word1">{{$data.$language.aword1}}</view>
				<view class="word2">{{$data.$language.aword2}}</view>
				<!-- <view class="word3">{{$data.$language.aword3}}</view> -->
			</view>
			<view class="line5">
				<view class="word1">
					<view class="number">
						{{type0}}
					</view>
					<view class="letter">USDT</view>
				</view>
				<view class="word2">
					<view class="number">
						{{type1}}
					</view>
					<view class="letter">USDT</view>
				</view>
				<!-- <view class="word3">
					<view class="number">
						{{type2}}
					</view>
					<view class="letter">USDT</view>
				</view> -->
			</view>
		</view>
		<view class="allList">
			<!-- <view class="classify"> -->
			<u-tabs :list="list1" @click="click" :scrollable="false"></u-tabs>
			<!-- </view> -->
			<view class="allDetails">

				<mescroll-uni class="mescroll-uni" ref="mescrollRef" :fixed="false" @init="mescrollInit"
					@down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
					<block v-if="logdata.length>0">
						<view class="mescroll-main">
							<view class="detail1" v-for="(item,index) in logdata" :key="index">
								<view class="kilstview">
									<image src="../../static/caifubeifen_slices/usdtimgs.png" v-if="item.coin=='usdt'"
										mode="">
									</image>
									<image src="../../static/caifubeifen_slices/woneimgs.png" v-else mode=""></image>
									<view class="middle">
										<view class="letter" v-if="item.coin=='usdt'">
											USDT
										</view>
										<view class="letter" v-else>
											WONE
										</view>
										<view class="date">
											{{ item.create_time}}
											<!-- {{ formatTime(item.createtime)}} -->
										</view>
									</view>
								</view>

								<view class="right">
									<view class="number">
										+{{item.usdt}}
									</view>
									<view class="word" v-if="item.type==9||item.type==10">
										{{$data.$language.aword1}}
									</view>
									<view class="word" v-else-if="item.type==11">
										{{$data.$language.aword2}}
									</view>
									<view class="word" v-else-if="item.type==12">
										{{$data.$language.aword4}}
									</view>
									<!-- <view class="word" v-else-if="item.coin=='wone'">
									{{$data.$language.aword3}}
								</view> -->
								</view>
							</view>
						</view>
					</block>
					<view style="text-align: center;padding: 48px;" v-else>
						{{$data.$language.Ticnda}}
					</view>
				</mescroll-uni>



				<!-- <view class="detail1 detail2">
					<image src="../../static/钱包详情_slices/bianzu.png" mode=""></image>
					<view class="middle">
						<view class="letter">
							USDT
						</view>
						<view class="date">
							06/25 09:41
						</view>
					</view>
					<view class="right">
						<view class="number">
							+{{type1}}
						</view>
						<view class="word">
							动态收益
						</view>
					</view>
				</view>

				<view class="detail1 detail2">
					<image src="../../static/钱包详情_slices/bianzu.png" mode=""></image>
					<view class="middle">
						<view class="letter">
							USDT
						</view>
						<view class="date">
							06/25 09:41
						</view>
					</view>
					<view class="right">
						<view class="number">
							+{{type2}}
						</view>
						<view class="word">
							节点分红
						</view>
					</view>
				</view>

				<view class="detail1 detail2">
					<image src="../../static/钱包详情_slices/bianzu.png" mode=""></image>
					<view class="middle">
						<view class="letter">
							USDT
						</view>
						<view class="date">
							06/25 09:41
						</view>
					</view>
					<view class="right">
						<view class="number">
							+{{type0}}
						</view>
						<view class="word">
							静态收益
						</view>
					</view>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import drawer from "../../my-components/drawer/drawer.vue"
	import languageMask from "../../my-components/languageMask/languageMask.vue"
	import zhCN from '@/locales/zh-CN.js'
	import enUS from '@/locales/en-US.js'
	import trCN from '@/locales/tr-CN.js'
	import {
		getBonus,
		getMyteam,
		getMYsix
	} from '@/api/index.js';
	import MescrollMixin from 'mescroll-uni/mescroll-mixins.js';
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				array: [
					// { name: '总资产',count_usdt:0 }, 
					{
						name: 'USDT',
						count_usdt: 0
					}, {
						name: 'WONE',
						count_usdt: 0
					}
				],
				index: 0,
				// $language: uni.getStorageSync('locale') == 'en-US' ? enUS : zhCN,
				isDrawerOpen: false,
				isOpenMask: false,
				code: '',
				msg: '',
				time: '',
				count_usdt: '',
				type0: '',
				type1: '',
				type2: '',
				logdata: [],

				list1: [{
						name: uni.getStorageSync('locale') == 'en-US' ? 'Whole' : '全部',
					}, {
						name: uni.getStorageSync('locale') == 'en-US' ? 'Share profit' : '分享收益',
					}, {
						name: uni.getStorageSync('locale') == 'en-US' ? 'Management income' : '管理收益',
					},
					// {
					// 	name: uni.getStorageSync('locale') == 'en-US' ? 'Node dividend' : '節點分紅',
					// },
				],
				itemindex: '99',
				page: 1,
				levelSl: '',
				Shoetrue: true,
				wone_usdt: 0,
				indexshoebox: 0,


				mescroll: null,
				downOption: {},
				upOption: {
					page: {
						size: 10
					},
					noMoreSize: 5,
					empty: {
						tip: 'No Data'
					}
				},
				// 列表数据
				dataList: []

			}
		},
		// computed: {
		//    getTypeContent() {
		//      if (this.logdata.data.type === '0') {
		//        return '静态收益'; // 根据类型 A 返回的内容
		//      } else if (this.logdata.data.type === '1') {
		//        return '动态收益'; // 根据类型 B 返回的内容
		//      } else if(this.logdata.data.type === '2'){
		//        return '节点收益'; // 默认情况下返回的内容
		//      }
		//    }
		//  },
		onReachBottom() {
			console.log('滑动到距离底部100px的时候触发,可以放 。。业务逻辑');
			this.onlisrse()
		},
		onLoad() {
			var translate = uni.getStorageSync('locale')
			if (translate == 'en-US') {
				this.$data.$language = enUS
			} else if (translate == 'zh-CN') {
				this.$data.$language = zhCN
			} else {
				this.$data.$language = trCN
			}
			// this.array[0].name = this.$data.$language.dtest
			// this.loadData()
			this.monxlist()
		},
		methods: {
			mescrollInit(mescroll) {
				this.mescroll = mescroll;
			},
			downCallback() {
				this.mescroll.resetUpScroll();
			},
			upCallback({
				num,
				size
			}) {
				getBonus({
						type: this.itemindex,
						limit: size,
						page: num
					},
					(data) => {
						// 处理成功返回的数据
						// this.count_usdt = parseInt(data.count_usdt).toFixed(2)
						// this.array[0].count_usdt = data.count_usdt
						this.array[0].count_usdt = data.usdt
						this.array[1].count_usdt = data.wone
						this.count_usdt = data.count_usdt
						this.type0 = data.type0
						this.type1 = data.type1
						this.type2 = data.type2
						// this.logdata = data.data
						this.wone_usdt = data.wone_usdt

						const res = data;
						if (num === 1) this.logdata = [];
						this.logdata = this.logdata.concat(res.data);
						this.$nextTick(() => {
							this.mescroll.endBySize(this.logdata.length, res.total);
						});
					},
					(errorMsg) => {
						// 处理请求失败或错误的情况
						console.error(errorMsg);
					}
				);
				// 	getRechargeList({
				// 			limit: size,
				// 			page: num
				// 		}, (res) => {
				// 			console.log("res", res);
				// 			if (res.code == 1) {
				// 				const {
				// 					total,
				// 					data
				// 				} = res.data;
				// 				if (num === 1) this.dataList = [];
				// 				this.dataList = this.dataList.concat(data);
				// 				this.$nextTick(() => {
				// 					this.mescroll.endByPage(data.length, total);
				// 				});
				// 			} else {
				// 				this.mescroll.endErr();
				// 				uni.showToast({
				// 					title: res.msg,
				// 					duration: 2000,
				// 					icon: 'error',
				// 					mask: true
				// 				});
				// 			}
				// 		},
				// 		(errorMsg) => {

				// 		},
				// 	);
			},

			// 获取自己资料
			loagistxs() {
				getMYsix((data) => {
						console.log(data.data)
						this.indexshoebox = data.data.parent_id
					},
					(errorMsg) => {
						var that = this
						uni.clearStorage()
						this.getcurentAddress()
						// 处理请求失败或错误的情况
						console.error(errorMsg);
					}
				);
			},
			bindPickerChange: function(e) {
				this.index = e.detail.value;
				// console.log(this.index)
				this.count_usdt = this.array[this.index].count_usdt
			},
			tranAccBtn() {
				console.log('mmmm')
				uni.navigateTo({
					url: '/pages/tranAcc/tranAcc'
				});
			},
			RechargeBtn() {
				// if(this.indexshoebox == 0 || this.indexshoebox == '' || this.indexshoebox ==null || this.indexshoebox == undefined){
				// 	var jjfihbi = this.$data.$language.jjfihbi
				// 	uni.showToast({
				// 		title:jjfihbi,
				// 		icon:"none",
				// 		duration:2000,
				// 	})
				// 	return
				// }else{
				uni.navigateTo({
					url: '/pages/Recharge/Recharge'
				});
				// }

			},
			monxlist() {
				getMyteam({
						page: ''
					},
					(data) => {
						// 处理成功返回的数据
						this.levelSl = data.level
					},
					(errorMsg) => {
						// 处理请求失败或错误的情况
						console.error(errorMsg);
					}
				);
			},
			refreshLanguage(locale) {
				if (locale === 'zh-CN') {
					this.$language = zhCN
				} else if (locale === 'en-US') {
					this.$language = enUS
				} else {
					this.$language = trCN
				}
				uni.reLaunch({
					url: '/pages/walletAll/walletAll'
				});

			},
			formatTime(timestamp) {
				const date = new Date(timestamp * 1000);
				const year = date.getFullYear();
				const month = date.getMonth() + 1;
				const day = date.getDate();
				const hours = date.getHours();
				const minutes = date.getMinutes();
				const seconds = date.getSeconds();

				const formattedDate = `${month}/${day} ${hours}:${minutes}`;
				return formattedDate;
			},
			toDetails() {
				uni.navigateTo({
					url: '/pages/details/details'
				})
				// this.$emit('close')				
				// uni.navigateBack()
			},
			openDrawer() {
				this.isDrawerOpen = true
			},
			closeDrawer() {
				this.isDrawerOpen = false
			},
			openMask() {
				this.isOpenMask = true
			},
			closeMask() {
				this.isOpenMask = false; // 遮罩层guanbi事件处理
			},
			loadData() {
				this.mescroll.triggerDownScroll()
				// getBonus({
				// 		type: this.itemindex,
				// 		page: this.page
				// 	},
				// 	(data) => {
				// 		// 处理成功返回的数据
				// 		// this.count_usdt = parseInt(data.count_usdt).toFixed(2)
				// 		// this.array[0].count_usdt = data.count_usdt
				// 		this.array[0].count_usdt = data.usdt
				// 		this.array[1].count_usdt = data.wone
				// 		this.count_usdt = data.count_usdt
				// 		this.type0 = data.type0
				// 		this.type1 = data.type1
				// 		this.type2 = data.type2
				// 		this.logdata = data.data
				// 		this.wone_usdt = data.wone_usdt
				// 		console.log(this.logdata, 'this.logdata');

				// 	},
				// 	(errorMsg) => {
				// 		// 处理请求失败或错误的情况
				// 		console.error(errorMsg);
				// 	}
				// );
			},
			onlisrse() {
				if (this.Shoetrue) {
					this.page++
					getBonus({
							type: this.itemindex,
							page: this.page
						},
						(data) => {
							// 处理成功返回的数据
							// this.count_usdt = parseInt(data.count_usdt).toFixed(2)
							// this.count_usdt = data.count_usdt
							// this.type0 = data.type0
							// this.type1 = data.type1
							// this.type2 = data.type2
							// this.logdata = data.log.data

							if (this.logdata.length == data.total) {
								this.Shoetrue = false
							}
							this.logdata.push(...data.data);
							console.log(this.logdata, '分页数据');

						},
						(errorMsg) => {
							// 处理请求失败或错误的情况
							console.error(errorMsg);
						}
					);
				}

			},
			click(item) {
				console.log('item', item);
				if (item.index == '0') {
					this.itemindex = 99
				} else if (item.index == '1') {
					this.itemindex = 0
				} else if (item.index == '2') {
					this.itemindex = 1
				} else if (item.index == '3') {
					this.itemindex = 2
				}
				this.Shoetrue = true
				this.page = 1
				this.loadData()
				// getBonus({
				// 		type: this.itemindex,
				// 		page: this.page
				// 	},
				// 	(data) => {
				// 		// 处理成功返回的数据
				// 		this.count_usdt = parseInt(data.count_usdt).toFixed(2)
				// 		this.type0 = data.type0
				// 		this.type1 = data.type1
				// 		this.type2 = data.type2
				// 		this.logdata = data.log.data
				// 		console.log(this.logdata, 'this.logdata');

				// 	},
				// 	(errorMsg) => {
				// 		// 处理请求失败或错误的情况
				// 		console.error(errorMsg);
				// 	}
				// );
			},
			// cAll(item){
			// 	if(item.index == '0'){
			// 	this.itemindex = 99
			// 	}
			// 	console.log(this.itemindex,'itemindex');
			// }
		},

		components: {
			drawer,
			languageMask
		}
	}
</script>

<style lang="less">
	@import "./walletAll.less";
</style>